package dk.cs.wolverine.client;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.LIElement;
import com.google.gwt.user.client.ui.Widget;

/**
 * This is a Widget which show ORDERED or UNORDERED list of text element
 * 
 * @author Siyalrach Anton Thomas
 */
public class TextList extends Widget{
	
	public static enum ListType {
		UNORDERED {
			public Element createElement() {
				return Document.get().createULElement();
			}
		},
		ORDERED {
			public Element createElement() {
				return Document.get().createOLElement();
			}
		};
		
		public abstract Element createElement();
	}
	
	public TextList(ListType listType){
		setElement(listType.createElement());
		setStylePrimaryName("html-list");
	}
	
	public void addItem(String text){
		LIElement liElement = Document.get().createLIElement();
		liElement.setInnerText(text);
		getElement().appendChild(liElement);
	}
}
